# -*- mode: sh -*-

# Disable an alias temporarily: $ \<alias>

# System
alias pls='ls -hAl'
alias plsfunc='ls_functions'
alias plszs='ls | xargs du -sh'
alias less-context='less --jump-target=10'

# Emacs
alias spcemacs='emacsclient --alternate-editor="" --create-frame --no-wait'
alias spckill='emacsclient --eval "(kill-emacs)"'
alias spcout='emacsclient --eval "(save-buffers-kill-emacs)"'
# alias spcger='emacsclient -nw --eval "(view-mode)"' # pager

# Ruby
alias rb='ruby'
alias rk='rake'

# Bundle exec
alias be='bundle exec'
alias beer='bundle exec rake'
alias beat='bundle exec autotest'
alias bjk='bundle exec jekyll serve'

# Bundler
# jobs = cores * 2; http://blog.mroth.info/blog/2014/10/02/rubygems-bundler-they-took-our-jobs/
alias big='bundle install -j4'
alias bback='bundle pristine'
alias burg='bundle outdated --groups --update-strict --patch --filter-minor --filter-patch'
alias bout='bundle outdated --groups'
alias bull='bundle update --strict --patch --quiet --jobs=4'
alias bup='bundle update'
alias bau='bundle audit check --update'
alias bcl='bundle clean'
alias brp='bundle console'

# Git
alias ggo='git go'
alias gst='git status-clean'
alias gdf='git diff-clean'
alias gdfs='git diff-staged'
alias gdel='git delete'
alias gdw='git down'
alias gou='git onup'
alias glr='git log-recent'
alias gli='git log-info'
alias glp='git log-pretty'
alias gsnk='git sneak'
alias gtke='git take'
alias gud='git untrack-dir'
alias guf='git untrack-file'
alias gap='git add-patch'
alias gdp='git discard-patch'
alias gup='git unstage-patch'
alias gsp='git stash-patch'
alias gmd='git amend'
alias ghw='git help-web'

alias gcm='git commit -m'
alias gcam='git commit -am'
alias gmrg='git merge'
alias gcln='git clone'
alias gps='git push'
alias gad='git add'
alias gaf='git add --all'
alias ghp='git help'

# Yarn
alias yin='yarn init'
alias yls='yarn list --depth=0'
alias yad='yarn add --dev'
alias yre='yarn remove'
alias you='yarn outdated'
alias yup='yarn upgrade'
alias yto='yarn test'
alias yat='yarn watch:test'
alias yex='yarn why'
alias ycl='yarn cache clean'
alias yuv='yarn version' # update package.json version

# OS specific

if [[ "$OSTYPE" == "linux-gnu" ]]; then
  alias upd='cp --update'
elif [[ "$OSTYPE" == 'darwin'* ]]; then
  alias drk='open /Applications/Racket*/bin/drracket'

  # Recursively delete `.DS_Store` files
  alias cleanup="find . -type f -name '*.DS_Store' -ls -delete"

  # Empty the Trash on all mounted volumes and the main HDD.
  # Also, clear Apple’s System Logs to improve shell startup speed.
  # https://apple.stackexchange.com/questions/98197/is-it-safe-to-delete-system-logs
  alias emptytrash="sudo rm -rfv /Volumes/*/.Trashes; sudo rm -rfv ~/.Trash; sudo rm -rfv /private/var/log/asl/*.asl"

  # Show/conceal hidden files in Finder
  alias showdots="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
  alias hidedots="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"

  # Show/hide all desktop icons
  alias hidedesktop="defaults write com.apple.finder CreateDesktop -bool false && killall Finder"
  alias showdesktop="defaults write com.apple.finder CreateDesktop -bool true && killall Finder"

  # Lock the screen
  alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend"

  # Reload the shell
  alias reload="exec ${SHELL} -l"

  # Brew
  alias bud='brew doctor && brew update'
  alias burp='brew upgrade'

  # rbenv
  alias rbl='rbenv install -l'
  alias rbi='rbenv install'
  alias rbv='rbenv versions'
  alias rbu='rbenv uninstall'
  alias rbg='rbenv global'
  alias rblo='rbenv local'

  # Skip downloads that match exactly existing files
  alias wg='wget --timestamping'
fi
